package com.eatme.web.sys.controller;

import com.eatme.web.common.vo.AppResponse;
import com.eatme.web.app.article.dao.model.UserVO;
import com.eatme.web.sys.dto.SysResourceDto;
import com.eatme.web.sys.entity.SysResource;
import com.eatme.web.sys.repository.SysResourceRepository;
import com.eatme.web.sys.service.SysResourceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("/resource/")
public class SysResourceController {

    @Autowired
    private SysResourceService sysResourceServiceImpl;

    @RequestMapping( "add")
    @ResponseBody
    public AppResponse add(@RequestBody SysResource sysResource){
        return sysResourceServiceImpl.add(sysResource);
    }


    @RequestMapping( "list")
    @ResponseBody
    public AppResponse list(){
        //List<SysResourceDto> list =  sysResourceServiceImpl.findList();
        List<SysResource> list = sysResourceServiceImpl.findList(0);
      return AppResponse.ok().data(list);
    }

    @RequestMapping( "delete/{id}")
    @ResponseBody
    public AppResponse delete(@PathVariable(value = "id") Integer id){
        return sysResourceServiceImpl.delete(id);
    }

    @RequestMapping( "detail/{id}")
    @ResponseBody
    public AppResponse detail(@PathVariable(value = "id") Integer id){
        return AppResponse.ok().data(sysResourceServiceImpl.getDetail(id));
    }

}
